/*
 * Created by Christopher King
 * Copyright (C) 2007 Christopher King, All Rights Reserved.
 */
package us.cirion.adventure.engine;

/**
 * AnyNoun indicates that all items are valid for a particular action. For
 * example, when dropping an item, use AnyNoun to permit any item to be dropped.
 * 
 * @author Chris
 */
public class AnyNoun extends Noun
{

	private static AnyNoun anyNoun;
	private Game game;

	private AnyNoun(Game game)
	{
		this.game = game;
		setText(Game.ANY_ITEM_STRING);
	}

	/**
	 * Change the location of whatever item was selected.
	 * 
	 * @param location The new location for the item.
	 */
	public void setLocation(ItemLocation location)
	{
		game.getCurrentNoun().setLocation(location);
	}

	/**
	 * Singleton accessor.
	 * 
	 * @param game The game being played.
	 * @return Singleton instance of AnyNoun.
	 */
	public static AnyNoun getInstance(Game game)
	{
		if (anyNoun == null)
		{
			anyNoun = new AnyNoun(game);
		}
		return anyNoun;
	}

	/**
	 * Reports whether the provided object is a valid noun.
	 * 
	 * @return <code>true</code> if the object is a noun, <code>false</code>
	 *         otherwise.
	 */
	public boolean equals(Object o)
	{
		if (this == o)
		{
			return true;
		} else if (o instanceof Noun)
		{
			return true;
		}
		return false;
	}

}
